package com.qidian.mes.md.service.impl;

import com.alibaba.fastjson2.JSON;
import com.qidian.mes.md.mapper.MdWorkMapper;
import com.qidian.mes.md.service.MdWorkService;
import com.qidian.mes.pojo.MdWork;
import com.qidian.mes.util.pojo.QdResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: CoolPro
 * @Description:
 * @Time: 2024-04-10 19:00
 **/
@Service
public class MdWorkServiceImpl implements MdWorkService {

    @Autowired
    private MdWorkMapper mdWorkMapper;

    @Override
    public QdResult insertMdWork(String mdWork) {
        mdWorkMapper.insertMdWork(JSON.parseObject(mdWork, MdWork.class));
        return QdResult.success();
    }

    @Override
    public QdResult deleteMdWorkById(Integer idWork) {
        mdWorkMapper.deleteMdWorkById(idWork);
        return QdResult.success();
    }

    @Override
    public QdResult updateMdWork(String mdWork) {
        mdWorkMapper.updateMdWork(JSON.parseObject(mdWork, MdWork.class));
        return QdResult.success();

    }

    @Override
    public QdResult getMdWorkById(Integer idWork) {
        return QdResult.success(mdWorkMapper.getMdWorkById(idWork));
    }

    @Override
    public QdResult getMdWorksByName(Integer idWorkshop, Integer idProgress, String name, Integer offset, Integer limit) {
        MdWork work = new MdWork();
        work.setIdWorkshop(idWorkshop);
        work.setIdProgress(idProgress);
        work.setName(name);
        return QdResult.success(mdWorkMapper.getMdWorksByName(work, offset, limit));

    }

    @Override
    public QdResult getCount() {
        return QdResult.success(mdWorkMapper.getCount());
    }

    @Override
    public QdResult deleteMall(Integer[] ids) {
        mdWorkMapper.deleteMdWorksByIds(ids);
        return QdResult.success();
    }

    @Override
    public QdResult getAllInfo() {
        return QdResult.success(mdWorkMapper.getAllInfo());
    }
}
